<!--设置模块唯一ID-->
<div id="lzk_chukubiao">
<!--标题、面包屑-->
<section class="content-header">
    <h1>
        出库表
        <small>绿植库</small>
    </h1>
    <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
        <li>绿植库</li>
        <li class="active">出库表</li>
    </ol>
</section>
<!--列表-->
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <div class="btn-group pull-left" data-type="actionBar">
                        <button type="button" class="btn btn-default" data-action="bumen_chuku">出库-部门经理审批</button>
                        <button type="button" class="btn btn-default" data-action="lvzhi_chuku">出库-绿植库经理审批</button>
                        <button type="button" class="btn btn-default" data-action="jinji_lvzhi_chuku">紧急出库-绿植库经理审批</button>
                    </div>
                    <div class=" pull-right" data-type="columnControl">
                    </div>
                    <div class=" pull-right " data-type="searchControl">
                    </div>
                    <div class="clearfix"></div>
                </div>
                <div class="box-body">
                    <table class="table table-bordered table-striped table-hover" style="width: 1500px"></table>
                </div>
            </div>
        </div>
    </div>
</section>

<script>
    USEN(function () {
        //模块ID(全系统唯一)
        var id = "#lzk_chukubiao";
        var bumen_chukuId = "lzk_chukubiao_bumen_confirm";
        var lvzhi_chukuId = "lzk_chukubiao_lvzhi_confirm";
        var jinji_lvzhi_chukuId = "lzk_chukubiao_jinji_lvzhi_confirm";

        //定义页面变量
        var $el = $(id);
        var $actionBar = $el.find("[data-type=actionBar]");
        var tableId = id + " table.table";
        var $table = $(tableId);
        var myTable;


        //定义增\删\改 方法
        var editor = {
            bumen_chuku: function (data) {
                USEN.load(USEN.router[bumen_chukuId]);
            },
            lvzhi_chuku: function (data) {
                USEN.load(USEN.router[lvzhi_chukuId]);
            },
            jinji_lvzhi_chuku: function (data) {
                USEN.load(USEN.router[jinji_lvzhi_chukuId]);
            }
        };


        // 绑定列表编辑按钮事件
        $actionBar.find("[data-action]").on("click", function () {
            var action = $(this).data("action");
            var $selected = $table.find('tr.selected');
            switch (action) {
                case "bumen_chuku" :
                    if ($selected.length > 0) {
                        editor.bumen_chuku();
                    } else {
                        //提示"请选中要修改的行"
                        USEN.modal({
                            title: "提示",
                            content: "请选中要修改的行.",
                            cancelBtn: true,
                            cancelTxt: "关闭"
                        })
                    }
                    break;
                case "lvzhi_chuku" :
                    if ($selected.length > 0) {
                        editor.lvzhi_chuku();
                    } else {
                        //提示"请选中要修改的行"
                        USEN.modal({
                            title: "提示",
                            content: "请选中要修改的行.",
                            cancelBtn: true,
                            cancelTxt: "关闭"
                        })
                    }
                    break;
                case "jinji_lvzhi_chuku" :
                    if ($selected.length > 0) {
                        editor.jinji_lvzhi_chuku();
                    } else {
                        //提示"请选中要修改的行"
                        USEN.modal({
                            title: "提示",
                            content: "请选中要修改的行.",
                            cancelBtn: true,
                            cancelTxt: "关闭"
                        })
                    }
                    break;
            }
        });

        //初始化datatable数据列表
        myTable = new USEN.Datatable({
            //设置ID
            "id": tableId,
            //设置列控制模块容器
            "columnControl": id + " [data-type=columnControl]",
            //设置搜索模块容器
            "searchControl": id + " [data-type=searchControl]",
            //配置服务
            "ajax": "./simdata/common_table_ation.json",
            //列设置
            "columns": [
                {
                    data: null,
                    defaultContent: '',
                    className: 'select-checkbox',
                    orderable: false, searchable: false,
                    width: "30px"
                },
                { "title": "使用项目",  width: '200px', "data": "p0"},
                { "title": "申请人", "data": "p1"},
                { "title": "申请人所属部门", "data": "p2"},
                { "title": "金额", "data": "p3"},
                { "title": "时间", "data": "p4" },
                { "title": "状态", "data": "p5" },
                { "title": "出库单类型", "data": "p6" }
            ]
        })
    });
</script>
</div>